using System.Collections.Generic;
using System.Data;

namespace DL
{
    public class DP_Task : DataParser
    {
        public override string GetLocalCsvName() => "游戏常规数据 - 任务";

        public override void DoParse(DataTable table)
        {
            var list = new List<object>();
            var totalRow = table.Rows.Count;
            for (int i = 2; i < totalRow; i++)
            {
                var id = table.Rows[i][0].ToString();
                if (string.IsNullOrEmpty(id))
                {
                    continue;
                }

                var name = table.Rows[i][1].ToString();
                var tips = table.Rows[i][2].ToString();
                var pgs = table.Rows[i][3].ToString();
                var rwd = table.Rows[i][4].ToString();
                var dict = new Dictionary<string, object>(5);
                dict.Add(nameof(id), id);
                dict.Add(nameof(name), name);
                dict.Add(nameof(tips), tips);
                dict.Add(nameof(pgs), pgs);
                dict.Add(nameof(rwd), rwd);
                list.Add(dict);
            }

            var json = MiniJson.Json.Serialize(list);
            json = MakeJsonEasyToRead(json);

            WriteFile(json, "TaskCfgData.json");
        }
    }
}
